package org.oos.model;

import java.io.Serializable;

import org.oos.atom.elements.Area;
import org.oos.util.Log;

/**
 * This class is the model of a Location TODO
 * 
 * @author pablo.gonzalez@11870.com
 * 
 */
public class SiteLocation implements Serializable, Cloneable {
	private static final long serialVersionUID = -6107776967486587319L;

	/* Compulsory */
	private Float latitude;
	private Float longitude;
	private String address;
	private Area locality;
	private Area country;

	/* Conditional */
	private Area subDependentLocality;
	private Area dependentLocality;
	private Area subAdministrativeArea;
	private Area administrativeArea;

	private static SiteLocation flyweight;

	public static SiteLocation create() {
		try {
			return flyweight.clone();
		} catch (CloneNotSupportedException e) {
			Log.e(e);
			return new SiteLocation();
		}
	}

	@Override
	public SiteLocation clone() throws CloneNotSupportedException {
		return (SiteLocation) super.clone();
	}

	public SiteLocation() {
		// default constructor
	}

	public Float getLatitude() {
		return latitude;
	}

	public void setLatitude(Float latitude) {
		this.latitude = latitude;
	}

	public Float getLongitude() {
		return longitude;
	}

	public void setLongitude(Float longitude) {
		this.longitude = longitude;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Area getSubDependentLocality() {
		return subDependentLocality;
	}

	public void setSubDependentLocality(Area subDependentLocality) {
		this.subDependentLocality = subDependentLocality;
	}

	public Area getDependentLocality() {
		return dependentLocality;
	}

	public void setDependentLocality(Area dependentLocality) {
		this.dependentLocality = dependentLocality;
	}

	public Area getLocality() {
		return locality;
	}

	public void setLocality(Area locality) {
		this.locality = locality;
	}

	public Area getSubAdministrativeArea() {
		return subAdministrativeArea;
	}

	public void setSubAdministrativeArea(Area subAdministrativeArea) {
		this.subAdministrativeArea = subAdministrativeArea;
	}

	public Area getAdministrativeArea() {
		return administrativeArea;
	}

	public void setAdministrativeArea(Area administrativeArea) {
		this.administrativeArea = administrativeArea;
	}

	public Area getCountry() {
		return country;
	}

	public void setCountry(Area country) {
		this.country = country;
	}

	public boolean hasCoordinates() {
		return getLatitude() != null && getLongitude() != null;
	}

}
